<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>主页</title>
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/plugins/build/css/app.css" media="all">
</head>
<body>
<div class="container">
    <form class="layui-form custom_search_form" action="">
                <div class="layui-form-item">
            <label class="layui-form-label">订单编号</label>
            <div class="layui-input-block">
                <input type="text" name="orderSn" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="custom_btn_search">
            <button class="layui-btn" lay-submit="" lay-filter="search">搜索</button>
        </div>
    </form>
    <table id="table" lay-filter="table"></table>
</div>
<script src="/plugins/layui/layui.js"></script>
<script src="/plugins/date/date.js"></script>
<script src="/plugins/common.js"></script>
<script>
    //配置项：列表地址、删除地址、编辑页面、详情页面
    var listUrl = SERVER_URL+"/shopOrder/list";
    var detailUrl = "detail.html";

    //配置项：列表高度
    var tableHeight = "full-140";

    //配置项：主键名称
    var ID = "orderId";

    layui.use(['jquery', 'table', 'form','layer'], function() {
        var $ = layui.jquery;
        var form = layui.form;
        var table = layui.table;
        layer.config({
            anim: 5
            ,offset: '50px'
            ,maxmin: true
            ,isOutAnim: false
        })

        //配置项：列表项
        table.render({
            elem: '#table'
            ,height: tableHeight
            ,url: listUrl
            ,page: true
            ,cols: [[
                {field: 'orderSn', title: '订单编号'},
                {field: 'outerSn', title: '支付单号'},
                {field: 'buyerName', title: '购买者名称'},
                {field: 'buyerPlatform', title: '购买平台', templet: '#buyerPlatform'},
                {field: 'payMode', title: '购买方式'},
                {field: 'payTime', title: '支付时间'},
                {field: 'payStatus', title: '支付状态', templet: '#payStatus'},
                {field: 'orderState', title: '订单状态', templet: '#orderState'},
                {field: 'orderTotalPrice', title: '订单总金额', templet: '#orderTotalPrice'},
                {field: 'orderPayPrice', title: '订单支付金额', templet: '#orderPayPrice'},
                {field: 'orderFreightPrice', title: '运费价格', templet: '#orderFreightPrice'},
                {field: 'createTime', title: '订单创建时间', width:200, templet:'#createTime'},
                {fixed: 'right', title: '操作', width:50, toolbar: '#toolBar'},
            ]]
        });

        //列表行末工具栏
        table.on('tool(table)', function(obj){
            if(obj.event === 'detail'){
                layer.open({
                    area: ['800px', '500px']
                    ,type: 2
                    ,title: '查看'
                    ,content: detailUrl+"?id="+obj.data[ID]
                });
            }
        });

        //条件搜索
        form.on('submit(search)', function(data){
            table.reload('table', {
                url: listUrl
                ,where: data.field
                ,page:{ curr: 1 }
                ,height: tableHeight
            });
            return false;
        });
    });

    //刷新列表
    function reload() {
        layer.closeAll();
        layer.msg('操作成功', {icon: 1,time: 1500}, function(){
            window.location.reload();
        })
    }
</script>

<script type="text/html" id="buyerPlatform">
    {{# if(d.buyerPlatform == 0){ }}
        PC
    {{#  } else if(d.buyerPlatform == 1) { }}
        安卓
    {{#  } else if(d.buyerPlatform == 2) { }}
        IOS
    {{#  } else if(d.buyerPlatform == 3) { }}
        微信
    {{#  } }}
</script>

<script type="text/html" id="payStatus">
    {{# if(d.payStatus == 0){ }}
        未付款
    {{#  } else if(d.payStatus == 1) { }}
        已付款
    {{#  } }}
</script>

<script type="text/html" id="orderState">
    {{# if(d.orderState == 10){ }}
        待付款
    {{#  } else if(d.orderState == 30) { }}
        待收货
    {{#  } else if(d.orderState == 40) { }}
        交易完成
    {{#  } }}
</script>

<script type="text/html" id="orderTotalPrice">
    {{d.orderTotalPrice.toFixed(2)}}&nbsp;元
</script>

<script type="text/html" id="orderPayPrice">
    {{d.orderPayPrice.toFixed(2)}}&nbsp;元
</script>

<script type="text/html" id="orderFreightPrice">
    {{d.orderFreightPrice.toFixed(2)}}&nbsp;元
</script>

<script type="text/html" id="createTime">
    {{#
    var date = new Date();
    date.setTime(d.createTime);
    return date.Format("yyyy-MM-dd hh:mm:ss");
    }}
</script>

<script type="text/html" id="toolBar">
    <div class="layui-btn-group custom_btn_group">
        <button class="layui-btn layui-btn-primary layui-btn-sm" lay-event="detail">
            <i class="layui-icon">&#xe63e;</i>
        </button>
    </div>
</script>
</body>
</html>
